<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/css/bootstrap.css" rel="stylesheet">

    <link href="https://cdn.bootcss.com/jquery.bootstrapvalidator/0.5.3/css/bootstrapValidator.css" rel="stylesheet">

    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>

    <script src="https://cdn.bootcss.com/jquery.bootstrapvalidator/0.5.3/js/bootstrapValidator.js"></script>

    <script src="https://cdn.bootcss.com/jquery.bootstrapvalidator/0.5.3/js/language/zh_CN.js"></script>

    <script type="text/javascript" src="http_cdn.bootcdn.net_ajax_libs_twitter-bootstrap_4.5.3_js_bootstrap.bundle.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>

    <link type="text/css" rel="stylesheet" href="http_cdn.bootcdn.net_ajax_libs_twitter-bootstrap_4.5.3_css_bootstrap-grid.css">
    <script type="text/javascript" src="http_cdn.bootcdn.net_ajax_libs_jquery_3.5.1_jquery.js"></script>

    <script>
        $(function () {
            let id = getQueryString("id");
            let params = {
                id: id
            }
            $.get(CATEGORY_GET_URL,params,function (result) {
                if (result.status === 200) {
                    let category = result.data;
                    $("#name").val(category.name)
                }
            })
            $("#save").click(function () {
                let category = {}
                category.id = id;
                category.name = $("#name").val()
                $.post("",category,function (result) {
                    window.location.href="information.html"
                })
            });
        })

        $(function () {
            $("#save").click(function () {
                let category = {
                    name: $("#name").val(),
                    parent: $("#level").val(),
                    keyword: $("#kw").val(),
                    img: "",
                    create_date: $("#create_date").val(),
                    description: $("#description").val(),
                    cate_order: $(":input:radio").prop("checked") ? 1 : 0,
                };
                let params = {
                    category: JSON.stringify(category)
                };
                $.post("http://localhost:8080/category/add",params, function (result) {
                    if (result.status === 200) {
                        window.location.href = "information.html"
                    } else {
                        alert("添加失败");
                    }
                })
            });
        })

        function getQueryString(name) {
            let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
            let r = window.location.search.substr(1).match(reg);
            return r != null ? unescape(r[2]) : null
        }
    </script>

</head>
<body>
<div>
<div>
<div>
    <div class="row" style="background-color: pink;">
        <div class="col-md-4"><h2>美景家政信息平台</h2></div>
        <div class="col-md-4"></div>
        <div class="col-md-4">
            <span class="glyphicon glyphicon-off">

            </span>
        </div>
    </div>
    <div>
        <h2>新增广告</h2>
        <div class="form-group">
            <label for="name"></label>
            <h3>广告名称:<input id="name" type="text" class="form-control" name="name" style="width: 350px; height: 35px;"></h3>
        </div>
    </div>
</div>
</div>
</div>
<div class="row">
    <div class="col-md-4"><h3>广告封面:</h3></div>
    <div class="col-md-8">
        <img>
        <input type="button" style="height: 50px; width: 170px;" value="选择文件"></br>
        <h4>选择文件 选择文件 建议尺寸750*560px或4：3，JPG、PNG格式， 图片小于5M。</h4>
    </div>
</div>
<div class="row">
    <div class="col-md-4">
        <h3>生效时间:</h3>
    </div>
    <div class="col-md-8">
        <input type="text" style="height: 50px; width: 250px;">至<input type="text" style="height: 50px; width: 250px;">
    </div>
</div>
<div class="row">
    <div class="col-md-4"><h3>关联服务</h3>></div>
    <div class="col-md-8">
        <a href="seek.html"><input type="button" style="height: 50px; width: 190px;" value="关联服务项目"></a>
    </div>
</div>

<div class="row">
    <div class="col-md-4"></div>
    <div class="form-group col-md-4">
        <label for="save"></label>
        <input type="button" class="btn btn-info" value="取消">
        <input id="save" type="button" class="btn btn-info" value="保存">
    </div>
    <div class="col-md-4">
    </div>
</div>
</body>
</html>
